package com.zhongnan.demo7.executors;

import java.sql.SQLOutput;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MyThreadExecutors {
    public static void main(String[] args) throws InterruptedException {
        // ExecutorService newCachedThreadPool 创建一个线程池
        // 创建一个线程池 默认为int的最大值
        ExecutorService executorService = Executors.newCachedThreadPool();
        // Executors帮助我们创建线程池
        // executorService控制线程
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName() + "线程");
        });
        //Thread.sleep(2000);
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName() + "线程");
        });
        executorService.shutdown();
    }
}
